<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/21 0021
 * Time: 22:21
 */

namespace App\WebSocket;


class Index
{
    public function open(\Swoole\WebSocket\Server $server, $request)
    {
        echo "server: handshake success with fd{$request->fd}\n";
    }

    public function message(\Swoole\WebSocket\Server $server, $frame)
    {
        $server->push($frame->fd, "this is server");
    }

    public function close(\Swoole\WebSocket\Server $server, $fd)
    {
        echo "client {$fd} closed\n";
        $server->close($fd);
    }
}